package cn.bluethink.timescaledb.entity;

import java.util.*;

public class RequestDTO{

    private List<Dynamic> data;

    private String tableName;

    public List<Dynamic> getData() {
        return data;
    }

    public void setData(List<Dynamic> data) {
        this.data = data;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }


    /**
     * @return 返回数据属性名 但不包括number和time这两个固定属性
     */
    public List<String> getTableKeys(){
        List<String> key = new ArrayList<>();
        for (Map<String,String> map: getData().get(0).getLocation()){
            Iterator it = map.entrySet().iterator() ;
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next() ;
                String mapKey = (String) entry.getKey();
                if (!"time".equals(mapKey) && !"number".equals(mapKey)){
                    key.add(mapKey);
                }
            }
        }
        return key;
    }
}
